package com.jike.noobmoney.adapter;


import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.jike.noobmoney.R;
import com.jike.noobmoney.contants.ConstantValue;
import com.jike.noobmoney.entity.TaskListEntity;


/**
 * Created by kekex on 2018/9/8.
 * 首页Performer的列表adapter
 */

public class TaskListAdapter extends BaseRecyclerAdapter<TaskListEntity.TaskBean> {


    private Context context;

    public TaskListAdapter(Context context) {
        super(R.layout.item_task_list);
        this.context = context;
    }

    @Override
    protected void onBindViewHolder(SmartViewHolder holder, TaskListEntity.TaskBean item, int position) {
        ImageView imageView = (ImageView) holder.findViewById(R.id.iv_img);
        if (!TextUtils.isEmpty(item.getPicture())) {
            RoundedCorners roundedCorners = new RoundedCorners(14);
            RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
            Glide.with(context).load(ConstantValue.TX_IMG_BASEURL + item.getPicture()).apply(options).into(imageView);
        } else {
            imageView.setImageResource(R.drawable.task_item_icon);
        }

        holder.text(R.id.tv_tasktitle, TextUtils.isEmpty(item.getTaskname()) ? "小白任务" : item.getTaskname());
        holder.text(R.id.tv_remain, "剩余" + item.getLastnumber() + "份");
        holder.text(R.id.tv_finish,   item.finishnumber+"人已赚");
        holder.text(R.id.tv_title,   item.title+"");
        holder.text(R.id.tv_money, "" + item.getMoney());

        ImageView viewById = (ImageView) holder.findViewById(R.id.iv_status);
        int receive = item.getReceive();
        switch (receive) {
            case 0:
                //待领取
                viewById.setVisibility(View.VISIBLE);
                viewById.setImageResource(R.drawable.iv_status_weilingqu);
                break;
            case 1:
                //待提交
                viewById.setVisibility(View.VISIBLE);
                viewById.setImageResource(R.drawable.iv_status_daitijiao);
                break;
            case 2:
                //审核失败
                viewById.setVisibility(View.GONE);

                break;
            case 3:
                //审核中
                viewById.setVisibility(View.VISIBLE);
                viewById.setImageResource(R.drawable.iv_status_daishenhe);
                break;
            case 4:
                //已完成
                viewById.setVisibility(View.VISIBLE);
                viewById.setImageResource(R.drawable.iv_status_yiwancheng);
                break;
        }

    }
}
